<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <title>徐翔yyds</title>
</head>
<body>
<pre>
<?php
/*
 * 常量：
 * MD5KEY: 各单位密码的 md5sum
 */
const MD5KEY = [
    "dddd" => "270b85586c36c685c098fcd7a41aaf73",
    "304"  => "4de04b47b57a1a8247f845abd89f5b0f",
    "305"  => "5a7dd969f0283b6a9813bc243b91762b",
    "306"  => "e91321f73dee3823e4165bd7a8abf8bd",
    "307"  => "d1a802815b9216f774cf42e92f93cb00",
    "308"  => "1e26600c6e9dcc06b71ba01f8d9c5545",
    "309"  => "9e850532883621bf2987cae121e94390",
    "test" => "c4d038b4bed09fdb1471ef51ec3a32cd", // password := 114514
];

/*
 * $key: 密码
 * $index_: 要删除条目的 index_
 * $class: 操作对应的表
 */
$key     = $_POST["key"];
$index_  = $_POST["index_"];
$class   = $_POST["classes"];
$echoStr = "\n\n----------\n以下是命令回显\n\n";


if (md5($key) != MD5KEY["$class"]) {
    die("Success!");
}


try {
//  $connPdo = new PDO("mysql:host=127.0.0.1:3306;dbname=test;charset=utf8", "root", "");
    $connPdo = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'squidward_top', '789456');
    $connPdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);


    $statement =
        "DELETE FROM test.$class\n
 WHERE index_ = $index_";
    $returnValue = $connPdo->exec($statement);
    $echoStr .= "$statement\n\nwith PDO return value $returnValue\n\n";

    echo $echoStr;
} catch (PDOException $e) {
    die("die 了，以下回显是人为输出的 =>\n{$e->getMessage()}");
}
?>
</pre>
</body>
